package com.information.manage.basic.audit.controller;

import com.information.manage.basic.audit.model.query.AuditCurrentTasksQuery;
import com.information.manage.basic.audit.model.query.FindAuditTaskQuery;
import com.information.manage.basic.audit.service.AuditTaskService;
import com.information.manage.basic.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

@Api(tags = "审核任务")
@RestController
@RequestMapping("/audit/task")
public class AuditTaskController {

    @Autowired
    private AuditTaskService auditTaskService;

    @GetMapping(value="/page")
    @ApiOperation(value = "分页查询", notes = "分页查询")
    public Result getAuditTemplates(HttpServletRequest request, @Valid FindAuditTaskQuery findAuditTaskQuery) {
        return auditTaskService.auditTasksPage(request, findAuditTaskQuery);
    }

    @PostMapping("/auditCurrentTasks")
    @ApiOperation(value = "审核当前任务", notes = "审核当前任务")
    public Result examineTasks(HttpServletRequest request, @RequestBody @Valid AuditCurrentTasksQuery auditCurrentTasksQuery){
        return auditTaskService.examineTask(request, auditCurrentTasksQuery);
    }

    @GetMapping("/feedback/{auditTaskId}")
    @ApiOperation(value = "获取审核反馈", notes = "获取审核反馈")
    public Result getFeedback(@PathVariable Integer auditTaskId){
        return auditTaskService.getAuditFeedByAuditTaskId(auditTaskId);
    }


}
